package com.bawei.base.utils

import okhttp3.Interceptor
import okhttp3.Response

class RetryInterceptor(val maxCount:Int) : Interceptor {
    var count = 1
    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request()
        var response = chain.proceed(request)
        while (!response.isSuccessful && count < maxCount){
            response = chain.proceed(request)
            count++
        }
        return response
    }
}